<template>
  <div id="app">
    <!-- 导航栏 -->
    <el-menu :default-active="activeMenu" class="el-menu-demo" mode="horizontal">
      <!-- 使用 <router-link> 来进行跳转 -->
      <el-menu-item :index="'/'">
        <router-link to="/">首页</router-link>
      </el-menu-item>
      <el-menu-item :index="'/restaurant'">
        <router-link to="/restaurant">餐厅</router-link>
      </el-menu-item>
      <el-menu-item :index="'/user'">
        <router-link to="/user">用户信息</router-link>
      </el-menu-item>
    </el-menu>

    <!-- 页面内容 -->
    <router-view></router-view>  <!-- 显示当前路由的组件 -->
  </div>
</template>

<script>
import { createApp } from 'vue';
import { ElMenu, ElMenuItem } from 'element-plus';
import 'element-plus/dist/index.css';
import router from './router';

export default {
  name: 'App',
  data() {
    return {
      activeMenu: window.location.pathname
    };
  },
  watch: {
    $route(to, from) {
      this.activeMenu = to.path;
    }
  },
};
</script>

<style scoped>

.el-menu-demo {
  background-color: #ffffff;
  border-bottom: 2px solid #e0e0e0;
}
.el-menu-item {
  font-size: 16px;
}
</style>
